<?php

namespace common\model;

use think\model\RelationModel;

class TaskRelationModel extends RelationModel
{
    const RELATION_TYPE_SUB_TODO = 'sub_todo'; // 子任务待办
    const RELATION_TYPE_DISMANTLE_TASK = 'dismantle_task'; // 工序子任务
    const RELATION_TYPE_TEMPLATE_TODO = 'template_todo'; // 模板待办
    const RELATION_TYPE_UPSTREAM = 'upstream'; // 下游
    const RELATION_TYPE_ENTITY = 'entity'; // 实体
    const RELATION_TYPE_RELATION = 'relation'; // 关联
    const RELATION_TYPE_LIST = [self::RELATION_TYPE_UPSTREAM,self::RELATION_TYPE_ENTITY, self::RELATION_TYPE_RELATION]; //包含旧数据--上游类型
    const RELATION_TYPE = [self::RELATION_TYPE_ENTITY, self::RELATION_TYPE_RELATION];

    //自动验证
    protected $_validate = [
        ['source_task_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['target_task_id', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT], //必须字段
        ['source_task_id,target_task_id,relation_type', '', '', self::MUST_VALIDATE, 'unique'],
    ];

    protected $_auto = [
        ['uuid', 'create_uuid', self::MODEL_INSERT, 'function'],
    ];
}
